﻿#pragma once
#include <faad.h>

class AACDecoder 
{
public:
    AACDecoder();
    ~AACDecoder();

    /** init AAC decoder */
    int open(unsigned char defObjectType = MAIN, unsigned long defSampleRate = 44100);

    /** destroy aac decoder */
    void close();

    /** 解码 */
    int decode(char* aacBuf, unsigned long int aacBufLen, char* outBuf);

private:
    /** parse AAC ADTS header, get frame length */
    unsigned int getFrameLenth(const char* aacHeader) const;

    /** AAC decoder properties */
    NeAACDecHandle _handle;
    unsigned long int _samplerate;
    unsigned char _channel;

    bool _init;
};